package com.snail.poker.dao.impl;

import com.snail.poker.dao.BaseDao;
import com.snail.poker.dao.EquipmentDao;
import com.snail.poker.model.Equipment;
import com.snail.poker.uitls.DateUtil;
import com.snail.poker.web.bean.PageBean;

/**
 * 设备登录平台记录的接口实现
 * 
 * @author Snail
 * 
 */
public class EquipmentDaoImpl extends BaseDao implements EquipmentDao {

	@Override
	public void addEquipment(Equipment equipment) throws Exception {
		// TODO Auto-generated method stub
		super.getHibernateTemplate().save(equipment);
	}

	@Override
	public PageBean queryEquipment() {
		// TODO Auto-generated method stub
		String hql = "from Equipment e order by e.createTime desc";
		return super.getPagination(hql);
	}

	@Override
	public void changeStatus(int equipmentSn, int status) throws Exception {
		// TODO Auto-generated method stub
		String hql = "update Equipment e set e.status = ? , e.logoutTime = ? where e.equipmentSn = ?";
		super.getSession().createQuery(hql).setParameter(0, status)
				.setParameter(1, DateUtil.getCurrDate()).setParameter(2,
						equipmentSn).executeUpdate();
	}
}
